package com.xingyun.kingdee.erp.common.model.param.opt;

import com.xingyun.kingdee.erp.common.model.param.base.ErpLoginParam;
import com.xingyun.kingdee.erp.common.model.param.base.ErpStandardParam;
import com.xingyun.kingdee.erp.common.model.param.opt.content.ErpSaveFormParamContent;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
 * @author lingo
 * @version v1.0
 * @date 2020/8/11 14:32
 * @Company www.xyb2b.com
 */

@Setter
@Getter
@ToString
public class ErpSaveFormParam<T> extends ErpStandardParam<ErpSaveFormParamContent<T>> {

    @ApiModelProperty("是否保存到草稿，默认为 false")
    private Boolean saveAsDraft;

    public ErpSaveFormParam() {
    }

    public static <T> ErpSaveFormParam<T> from(String formId, T data, ErpLoginParam erpLoginParam, boolean isSaveAsDraft){
        ErpSaveFormParam<T> saveFormParam = new ErpSaveFormParam<>();
        saveFormParam.setSaveAsDraft(isSaveAsDraft);
        saveFormParam.setFormId(formId);
        saveFormParam.setErpLoginParam(erpLoginParam);
        ErpSaveFormParamContent<T> paramContent = new ErpSaveFormParamContent<>();
        paramContent.setModel(data);
        saveFormParam.setParamContent(paramContent);
        return saveFormParam;
    }
}


